import { fileURLToPath, URL } from 'node:url'

import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
  server: {

    host: '172.20.10.5', // 例如 '192.168.1.100' ，若想监听所有IPv4地址，可写 '0.0.0.0'
    port: 5173,//端口
    cors: true,
    origin: 'http://172.20.10.5:5173',

    headers: {
      'Access-Control-Allow-Origin': '*', // 主应用获取子应用时跨域响应头
  },
},
  plugins: [
    vue(),
    vueDevTools(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },

})